package com.impress.model;

import java.util.ArrayList;
import java.util.List;




/**
 * Feed实体类
 * @author pluto
 * @version 1.0.1
 */
public class Feed {

	//member fields of feed table
	private int _id;
	private String atomID;
	private String title;
	private String sortID;

	public int get_id() {
		return _id;
	}
	public void set_id(int _id) {
		this._id = _id;
	}
	public String getAtomID() {
		return atomID;
	}
	public void setAtomID(String atomID) {
		this.atomID = atomID;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getSortID() {
		return sortID;
	}
	public void setSortID(String sortID) {
		this.sortID = sortID;
	}
	
	public List<Item> items = new ArrayList<Item>();
	
//	public List<Item> GetItems(){
//		return items;
//	}
//	
//	public void SetItems(List<Item> items){
//		this.items = items;
//	}
	
	/**
	 * 返回一条feed中的本地未读条目数
	 * @return 未读数
	 */
	public int GetUnreadCount(){
		int count = 0;
		for (Item item : items) {
			if (item.getReadState() == 0) {
				count++;
			}
		}
		return count;
	}
	
	/**
	 * 返回feed的本地所有条目数
	 * @return 所有条目数
	 */
	public int GetAllCount(){
		return items.size();
	}
	
	/**
	 * 是否只有一个本地未读条目
	 * @return
	 */
	public boolean HasSingleItem(){
		return (GetUnreadCount() == 1);
	}
	
	/**
	 * not implement yet.
	 */
	public void MarkAllRead(){
		//TODO mark all items in the feed as read
		
	}
	
}
